<template>
	<view class="container">
		<view class="item" v-for="(item, index) in seniclist" :key="index" @tap="toDetails(item.objectId)">
			<view class="pic">
				<image :src="item.img" mode="aspectFill"></image>
			</view>
			<view class="msg">
				<view class="name">{{item.name}}</view>
				<view class="intro">{{item.intro}}</view>
			</view>
		</view>
	</view>
</template>

<script setup>
	import { onLoad } from '@dcloudio/uni-app'
	import { ref } from 'vue'
	import { CONFIG } from "../../utils/config";

	const type = ref(1)
	onLoad(() => {
		getSenic()
	})

	const seniclist = ref([])
	async function getSenic() {
		let query = { "type": "1" }
		let queryStr = JSON.stringify(query)
		let res = await uni.$get(CONFIG.leanCloud_url + "/1.1/classes/SenicItem", { where: queryStr })
		if (res.statusCode == 200) {
			seniclist.value = res.data.results
		}
	}

	function toDetails(id) {
		uni.navigateTo({
			url: "/pages/playDetails/playDetails?id=" + id
		})
	}
</script>

<style scoped>
.container {
	display: flex;
	flex-direction: column;
	padding: 10px;
}

.item {
	display: flex;
	flex-direction: row;
	margin-bottom: 15px;
	border: 1px solid #eee;
	border-radius: 8px;
	overflow: hidden;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.pic {
	width: 120px;
	height: 80px;
}

.pic image {
	width: 100%;
	height: 100%;
}

.msg {
	flex: 1;
	padding: 10px;
	display: flex;
	flex-direction: column;
	justify-content: center;
}

.name {
	font-size: 16px;
	font-weight: bold;
	color: #333;
	margin-bottom: 5px;
}

.intro {
	font-size: 14px;
	color: #666;
}
</style>